/*
  Copyright © 2010  José Cavalcante Reis Neto

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#ifndef PHOTOELEMENT_H
#define PHOTOELEMENT_H

#include "toucheelement.h"

#include <gst/gst.h>
#include <gst/interfaces/xoverlay.h>
#include <QDialog>
#include "stage.h"

class PhotoWidget: public QDialog
{
    Q_OBJECT

public:
    PhotoWidget(Touche::Stage *stage);
    ~PhotoWidget();
//    void showOver(QWidget * window);

protected:
    void showEvent(QShowEvent *);

public slots:
    void takePhoto();

private:
    Touche::Stage *stage;

    GstElement *pipeline;
    GstElement *cameraSrc;
    GstElement *filter;
    GstElement *photoSink;
    GstElement *screenFilter;
    GstElement *sink;
    GstElement *screenSink;
    GstElement *videoTee;
    GstElement *queue1;

    GstElement *pipelinephoto;
    GstElement *queue2;
    GstElement *photoSrc;
    GstElement *photoFilter;

    int i;
    GstCaps *caps;
};

namespace Touche
{
    class PhotoElement : public Touche::Element
    {
        Q_OBJECT

        QGraphicsPixmapItem *m_item;
        QString file;

    public:
        using Element::id;

        PhotoElement();

        const QString &type() const;
        QRectF item(QGraphicsItem *parentItem) const;
        QVector<QString> menuOptions() const;

        void setFile(const QString &file);

    public slots:
        void onMenuActived(const QString &option);
    };
}

#endif // PHOTOELEMENT_H
